package binarysearch.test278;

/**
 * 第一个错误的版本
 *
 * @author code_yc
 * @version 1.0
 * @date 2020/7/11 11:05
 */
public class Solution1 extends VersionControl {

    public int firstBadVersion(int n) {
        int l = 0, r = n;
        while (l < r) {
            int mid = l + ((r - l) >> 1);
            if (isBadVersion(mid)) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }
        return l;
    }
}
